﻿/* ==============================================================================
 * 功能描述：BattlePanelRoleSkillInfo  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/5/8 15:53:17
 * ==============================================================================*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using ZZQFrameWork;

public class BattlePanelRoleSkillInfo : MonoBehaviour
{
    //private GridLayoutGroup skillGrid;

    private List<GameObject> skillItemList=new List<GameObject>(); 

    private RoleDataVO data;

    public RoleDataVO Data
    {
        get { return data; }
        set { data = value;
            UpdateShow();
        }
    }

    void Awake()
    {
        //skillGrid = transform.GetComponent<GridLayoutGroup>();
    }

    private void UpdateShow()
    {
        Debug.Log("有技能数量："+Data.skillList.Count);
        PoolManager.Instance.SpawnNeedGameObjects("BattlePanelSkillItem", Data.skillList.Count, skillItemList);
        for (int i = 0; i < Data.skillList.Count; i++)
        {
            skillItemList[i].transform.SetParent(transform,false);
            skillItemList[i].GetComponent<BattlePanelSkillItem>().Data = Data.skillList[i];
            EventTriggerListener.Get(skillItemList[i]).SetEventHandle(Enum_TouchEventType.OnClick, OnSkillItemClick);
        }
    }

    private void OnSkillItemClick(GameObject _listener, object _args, object[] _params)
    {
        Debug.Log("点击了技能");
        BattlePanelSkillItem item = _listener.GetComponent<BattlePanelSkillItem>();
        item.OnUseSkill();
    }
}